/*
 * libroxsd - a portable, lightweight XSD validation library
 * Copyright (C) 2012  Emmanuel Deloget
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA 
 */

#include <stdlib.h>
#include <string.h>

#include "roxsd-list.h"
#include "roxsd-compiler-successor.h"

xsdsucc_t *roxsdi_successor_add(xsdsucc_t *head, char *name)
{
	xsdsucc_t *s;

	s = malloc(sizeof(xsdsucc_t));
	if (!s)
		return head;

	memset(s, 0, sizeof(xsdsucc_t));
	s->name = name;

	return list_pushback(head, s);
}

void roxsdi_successor_free(xsdsucc_t *head)
{
	xsdsucc_t *cur;

	while (head) {
		cur = head;
		head = list_next(head);
		free(cur);
	}
}

int roxsdi_successor_contains(xsdsucc_t *head, char *name)
{
	xsdsucc_t *cur = head;

	while (cur) {
		if (strcmp(name, cur->name) == 0)
			return 1;
		cur = list_next(cur);
	}
	return 0;
}
